This patch adds a new boot parameter, dom0_ioports_disable, which
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Sun, 6 Nov 2005 15:39:02 +0000 (16:39 +0100)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Sun, 6 Nov 2005 15:39:02 +0000 (16:39 +0100)
accepts a comma seperated list of hex ioports and/or ioport ranges
(eg. dom0_ioports_disable=02f8-02ff,03f8-03ff), and applies them to dom0.

Signed-off-by: Jody Belka <knew (at) pimb (dot) org>
xen/arch/x86/domain_build.c

index 802a2538282d0e2575eb7b65af92ef23f04aff84..d3b8a7a4d0aa83560e7caa23080263e36bb54ca0 100644 (file)
@@ -56,6 +56,9 @@ boolean_param("dom0_shadow", opt_dom0_shadow);
 static unsigned int opt_dom0_translate = 0;
 boolean_param("dom0_translate", opt_dom0_translate);
 
+static char opt_dom0_ioports_disable[200] = "";
+string_param("dom0_ioports_disable", opt_dom0_ioports_disable);
+
 #if defined(__i386__)
 /* No ring-3 access in initial leaf page tables. */
 #define L1_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED)
@@ -91,6 +94,43 @@ static struct pfn_info *alloc_chunk(struct domain *d, unsigned long max_pages)
     return page;
 }
 
+static void process_dom0_ioports_disable()
+{
+    unsigned long io_from, io_to, io_nr;
+    char *t, *u, *s = opt_dom0_ioports_disable;
+
+    if ( *s == '\0' )
+        return;
+
+    while ( (t = strsep(&s, ",")) != NULL )
+    {
+        io_from = simple_strtoul(t, &u, 16);
+        if ( u == t )
+        {
+        parse_error:
+            printk("Invalid ioport range <%s> "
+                   "in dom0_ioports_disable, skipping\n", t);
+            continue;
+        }
+       
+        if ( *u == '\0' )
+            io_to = io_from;
+        else if ( *u == '-' )
+            io_to = simple_strtoul(u + 1, &u, 16);
+        else
+            goto parse_error;
+
+        if ( (*u != '\0') || (io_to < io_from) || (io_to >= 65536) )
+            goto parse_error;
+
+        printk("Disabling dom0 access to ioport range %04lx-%04lx\n",
+            io_from, io_to);
+
+        io_nr = io_to - io_from + 1;
+        physdev_modify_ioport_access_range(dom0, 0, io_from, io_nr);
+    }
+}
+
 int construct_dom0(struct domain *d,
                    unsigned long _image_start, unsigned long image_len, 
                    unsigned long _initrd_start, unsigned long initrd_len,
@@ -716,6 +756,8 @@ int construct_dom0(struct domain *d,
     physdev_modify_ioport_access_range(dom0, 0, 0x40, 4);
     /* PIT Channel 2 / PC Speaker Control. */
     physdev_modify_ioport_access_range(dom0, 0, 0x61, 1);
+    /* Command-line passed i/o ranges */
+    process_dom0_ioports_disable();
 
     return 0;
 }